package com.pls.action;

import java.util.ArrayList;

import com.pls.actionObjects.DeleteEmployeeSeatRequest;
import com.pls.actionObjects.DeleteEmployeeSeatResponse;
import com.pls.constants.ValidationErrorEnum;
import com.pls.domain.ExceptionError;
import com.pls.domain.ValidationError;
import com.pls.utilities.LogHelper;

public class DeleteEmployeeSeatHandler
		extends
		BaseRequestHandler<DeleteEmployeeSeatResponse, DeleteEmployeeSeatRequest> {

	public DeleteEmployeeSeatHandler(Class<DeleteEmployeeSeatResponse> tResponse) {
		super(tResponse);
		// TODO Auto-generated constructor stub
	}

	protected ArrayList<ValidationError> validate(
			DeleteEmployeeSeatRequest request) {
		ArrayList<ValidationError> errors = new ArrayList<ValidationError>();
		ValidationError valError;
		if (request == null) {
			valError = new ValidationError();
			valError.setMessage("Request is null.");
			valError.setErrorName(ValidationErrorEnum.NullRequest);
			errors.add(valError);
			return errors;
		}
		if (request.getEmployeeId() == 0) {
			valError = new ValidationError();
			valError.setMessage("Employee Id cannot be null.");
			valError.setErrorName(ValidationErrorEnum.InvalidRequestParameter);
			errors.add(valError);
		}
		if (request.getSeatCode() == null) {
			valError = new ValidationError();
			valError.setMessage("Seat code cannot be null.");
			valError.setErrorName(ValidationErrorEnum.InvalidRequestParameter);
			errors.add(valError);
		}

		return errors;
	}

	public DeleteEmployeeSeatResponse process(DeleteEmployeeSeatRequest request) {

		DeleteEmployeeSeatResponse response = new DeleteEmployeeSeatResponse();
		// call data layer

		try {
			//LOGGER NDI TOTOO
			
			
//			DeleteEmployeeSeatDAO deleteDAO = new DeleteEmployeeSeatDAO();

//			boolean isSuccesful = deleteDAO.deleteEmployeeSeat(
//					request.getEmployeeId(), request.getSeatCode());
//			response.setSuccessful(isSuccesful);
			
//		} catch (SQLException e) {
//			//ADD LOGGER
//			ExceptionError sqlError = new ExceptionError(e.getClass().toString(),
//					"Sorry, an SQL error occurred while accessing the DB.");
//			response.setExceptionError(sqlError);
		} catch (Exception e) {
			ExceptionError sqlError = new ExceptionError(e.getClass().toString(),
					"Sorry, an error occurred while accessing the DB.");
			response.setExceptionError(sqlError);
		}
		return response;
	}
}
